using UnityEngine;

public class BattleScript_LongshotFight : BattleEventListener
{
	[Header("-= Battle References/Setup =-")]
	[SerializeField]
	private PartyMember AsgorePartyMember;

	[SerializeField]
	private BattleAction[] LongshotBattleActions;

	[Space(5f)]
	[Header("-= Phase 1 =-")]
	[Header("Phase 1 References")]
	[SerializeField]
	private BattleAction Act_AsgoreAction_A_Action;

	private int Phase1_LongshotDialogueIndex;

	[Space(5f)]
	[Header("Phase 1 Dialogue")]
	[SerializeField]
	private CHATBOXTEXT[] Dialogue_LongshotBaseDialogueInOrder;

	[Space(5f)]
	[SerializeField]
	private CHATBOXTEXT Dialogue_IntroFlavorText;

	[Space(5f)]
	[SerializeField]
	private CHATBOXTEXT[] Dialogue_RandomFlavorText;

	[SerializeField]
	private BattleActiveEnemy Longshot;

	[SerializeField]
	private GameObject DialogueBubble_Default;

	[Space(5f)]
	[SerializeField]
	private BattleEnemyAttack Attack_TeamworkExclusive_LiquidFill;

	[SerializeField]
	private BattleEnemyAttack Attack_BubbleColumn;

	protected override void OnBattleStart(Battle battle)
	{
		Debug.Log($"Battle Begun: {battle}");
		BattleSystem.Instance.QueueBattleActions(LongshotBattleActions);
		BattleSystem.GetPartyMember(AsgorePartyMember).PartyMemberAction = Act_AsgoreAction_A_Action;
	}

	protected override void OnBattleEnd(Battle battle, BattleSystem.EndBattleTypes EndType)
	{
	}

	protected override void OnEnemyKilled(BattleActiveEnemy targetEnemy, float Damage, BattlePartyMember inflictor)
	{
		Debug.Log($"{targetEnemy} killed {inflictor} with {Damage} damage");
	}

	protected override void OnPlayerTurnHandler(int turnCount)
	{
		base.OnPlayerTurnHandler(turnCount);
	}

	protected override void OnEnemyTurnHandler(int turnCount)
	{
		base.OnEnemyTurnHandler(turnCount);
	}

	protected override void OnMemberDamaged(BattlePartyMember targetMember, float Damage)
	{
		Debug.Log($"{targetMember} damaged for {Damage} damage");
	}

	protected override void OnBattleStateChange(BattleSystem.BattleState newState, BattleSystem.BattleState oldState)
	{
		Debug.Log($"New Battle State: {newState} | Previous Battle State {oldState}");
		Longshot = battleSystem.BattleActiveEnemies[0];
		if (newState == BattleSystem.BattleState.PlayerTurn)
		{
			int num = Random.Range(0, Dialogue_RandomFlavorText.Length);
			BattleChatbox.Instance.RunText(Dialogue_RandomFlavorText[num], Random.Range(0, Dialogue_RandomFlavorText[num].Textboxes.Length), null, ResetCurrentTextIndex: true);
		}
		if (newState == BattleSystem.BattleState.Dialogue)
		{
			Longshot.QueuedDialogue.Add(Dialogue_LongshotBaseDialogueInOrder[0]);
			Longshot.SpecificTextIndexes.Add(Mathf.Clamp(Phase1_LongshotDialogueIndex, 0, Dialogue_LongshotBaseDialogueInOrder.Length + 1));
			Longshot.QueuedDialogueBubble.Add(DialogueBubble_Default);
		}
		if (newState == BattleSystem.BattleState.EnemyTurn)
		{
			Battle_PlayerSoul.Instance.CurrentSoulType = Battle_PlayerSoul.SoulType.Orange;
			Phase1_LongshotDialogueIndex++;
			battleSystem.QueuedBattleAttacks.Add(Attack_TeamworkExclusive_LiquidFill);
			battleSystem.QueuedBattleAttacks.Add(Attack_BubbleColumn);
		}
	}
}
